#!/usr/bin/env python
import rospy
from std_msgs.msg import String
import locale
from datetime import datetime


def publisher():
    locale.setlocale(locale.LC_ALL, 'zh_CN.UTF-8')
    pub = rospy.Publisher('topic', String, queue_size=10)
    rospy.init_node('my_node', anonymous=False)
    rate = rospy.Rate(1)  # 1Hz
    while not rospy.is_shutdown():
        msg = String()
        current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        msg.data = f"哈利路亚{current_time}"
        rospy.loginfo(msg.data)
        pub.publish(msg)
        rate.sleep()


if __name__ == '__main__':
    try:
        publisher()
    except rospy.ROSInterruptException:
        pass
